package com.myapp.api.mapper;

import com.myapp.api.entity.Dept;
import org.apache.ibatis.jdbc.SQL;

public class DeptSqlProvider {

    public String insertSelective(Dept record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("dept");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getDid() != null) {
            sql.VALUES("Did", "#{did,jdbcType=VARCHAR}");
        }
        
        if (record.getDname() != null) {
            sql.VALUES("Dname", "#{dname,jdbcType=VARCHAR}");
        }
        
        if (record.getDinfo() != null) {
            sql.VALUES("Dinfo", "#{dinfo,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.VALUES("CreateTime", "#{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.VALUES("UpdateTime", "#{updatetime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Dept record) {
        SQL sql = new SQL();
        sql.UPDATE("dept");
        
        if (record.getDid() != null) {
            sql.SET("Did = #{did,jdbcType=VARCHAR}");
        }
        
        if (record.getDname() != null) {
            sql.SET("Dname = #{dname,jdbcType=VARCHAR}");
        }
        
        if (record.getDinfo() != null) {
            sql.SET("Dinfo = #{dinfo,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.SET("CreateTime = #{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.SET("UpdateTime = #{updatetime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}